package com.sora.staservice.schedule;

import com.sora.staservice.service.DailyService;
import com.sora.staservice.utils.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;

import java.util.Date;

/**
 * @Classname: ScheduledTask
 * @Description:
 * @Author: Stonffe
 * @Date: 2023/1/15 14:16
 */
@ComponentScan
public class ScheduledTask {
    @Autowired
    private DailyService dailyService;

    //（0/5 * * * * ？）：每隔5秒执行一次
//    @Scheduled(cron = "0/5 * * * * ?")//指定cron表达式规则
   /* public void task01(){
        System.out.println("=========我执行了");
    }*/

    //在每天凌晨1点执行方法，把前一天的数据查询进行添加
//    @Scheduled(cron = "0 0 1 * * ? ")//指定cron表达式规则
    public void task02(){
        dailyService.createStatisticsByDay(DateUtil.formatDate(DateUtil.addDays(new Date(), -1)));
    }
}
